<?php
include_once("connexion.php");

if(isset($_GET['id'])){
	$id = 	$_GET['id'];
	$sql = "SELECT * FROM User WHERE id = ". $id;
	$result = mysqli_query($connexion, $sql);
	$user = mysqli_fetch_array($result);
}


$query =" SELECT * FROM Type ";
$resultat = mysqli_query($connexion, $query);

if( isset($_POST["valider"])){
	$nom = $_POST["nom"];
	$prenom = $_POST["prenom"];
	$email = $_POST["email"];
	$pwd = $_POST["pwd"];
	$pwd2 = $_POST["pwd2"];
	$type = $_POST["type"];
	$id = $_POST["id"];
	
	if($pwd == $pwd2 && $type != "0"){
		//Enregistrement en BDD
		$query ="UPDATE User SET nom = '".$nom."', prenom = '".$prenom."', email = '".$email."', password = '".$pwd."', id_type = ".$type." WHERE id = ".$id."";
		$res = mysqli_query($connexion, $query);
		
		include ("listUser.php");
		die();
	}
}


include ("editer.html");



?>









